package com.example.litterpainterdemo.data

import android.util.Log
import androidx.lifecycle.LiveData
import androidx.room.Delete
import androidx.room.Query
import androidx.room.Update
import com.example.litterpainterdemo.db.Picture
import com.example.litterpainterdemo.db.PictureDao
import com.example.litterpainterdemo.db.PictureDatabase


//中转站 实现数据的存储
class Repository {
    private val dao: PictureDao = PictureDatabase.db().getDao()


    suspend fun insertData(picture: Picture){
        dao.insertData(picture)
    }


    fun loadData():LiveData<List<Picture>>{
        return dao.queryData()
    }


    suspend fun deleteData(picture: Picture){
        dao.deleteData(picture)
    }


    suspend fun deleteAll(pictures:List<Picture>){
        dao.deleteAll(pictures)
    }


    suspend fun updateData(picture: Picture){
        dao.updateData(picture)
    }


}